import mockApi from "@/api/mockApi";

export default class facilityApi {
  static facilitys = [
    {id: 1, name: '充电应急灯', buildingId: 1, buildingName: '北区1栋', location: '二楼', lastMaintenanceDate: '2024-01-01', status: 10, createTime: '2024-01-01 12:12:12', modifyTime: '2024-02-02 13:13:13'},
    {id: 2, name: '高空摄像头', buildingId: 2, buildingName: '北区2栋', location: '一楼', lastMaintenanceDate: '2024-02-02', status: 20, createTime: '2024-02-02 12:12:12', modifyTime: '2024-03-03 13:13:13'},
    {id: 3, name: '顶楼换气扇', buildingId: 3, buildingName: '北区3栋', location: '顶楼', lastMaintenanceDate: '2024-03-03', status: 10, createTime: '2024-03-03 12:12:12', modifyTime: '2024-04-04 13:13:13'},
    {id: 4, name: '大厅电风扇', buildingId: 4, buildingName: '北区4栋', location: '大厅', lastMaintenanceDate: '2024-04-04', status: 20, createTime: '2024-04-04 12:12:12', modifyTime: '2024-05-05 13:13:13'}
  ]

  static async save (params) {
    console.log('facilityApi save params', params)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }

  static async find (params) {
    console.log('facilityApi find params', params)
    const response = await mockApi.queryPageSuccessfully(facilityApi.facilitys)
    return response.data
  }

  static async findById (id) {
    console.log('facilityApi findById id', id)
    let target = {}
    for (let a of facilityApi.facilitys) {
      if (a.id === id) {
        target = a
      }
    }
    const response = await mockApi.queryByIdSuccessfully(target)
    return response.data
  }

  static async del (id) {
    console.log('facilityApi del id', id)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }
}